package com.foreknow.mapping;

import com.foreknow.mapping.impl.GuestBookMapping;

import java.util.HashMap;
import java.util.Map;


/**
 * 工厂类
 * 1.使用单例
 */
public class MappingFactory {
    private static MappingFactory mappingFactory =null;
    public Map<String,EntityMapping> maps = new HashMap<>();
    private MappingFactory(){
    }
    public static MappingFactory getInstance(){
        if (mappingFactory == null) {
            mappingFactory = new MappingFactory();
            //向Map中保存xxxMapping对象
            mappingFactory.maps.put("guestbookmapping", new GuestBookMapping());
            mappingFactory.maps.put("adminapping", new GuestBookMapping());
            //mappingFactory.maps.put("xxxmapping",new xxxxMapping());
        }
        return mappingFactory;
    }

    //从Map获取元素的方法
    public EntityMapping getMap(String key){
        maps.get(key);
        return maps.get(key);
    }
}
